#include <string.h>

char *
ltrim(char *s, char c) 
{
    int i = 0;
    int len = strlen(s);
    if (s == NULL || s[0] == '\0') {
        return s;
    }

    while (s[i] == c) i++;

    if (i > 0) {
        memmove(s, s+i, len - i + 1);
    }

    return s;
}

char *
rtrim(char *s, char c)
{
    int i = 0;
    int len = strlen(s);

    if (s == NULL || s[0] == '\0') {
        return s;
    }

    for (i = len - 1; i >= 0 && s[i] == c; i--) {
        s[i] = '\0';
    }

    return s;
}
